﻿//   IAppStorageService.cs
//   Copyright (c) 2012 Eswar Prakash
// 
//    This library is free software; you can redistribute it and/or modify  
//    it  under the terms of the GNU Lesser General Public License version  
//    2.1 as published by the Free Software Foundation.                     
//                                                                          
//    This library is distributed in the hope that it will be useful, but   
//    WITHOUT ANY WARRANTY; without even the implied warranty of            
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     
//    Lesser General Public License for more details.                       
//                                                                          
//    You should have received a copy of the GNU Lesser General Public      
//    License along with this library; if not, write to the Free Software   
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
//    USA

namespace CKSAS.AppStorage.SharedService
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;
    using System.Runtime.Serialization;

    /// <summary>
    /// Represents the service contract for AppStorageService
    /// </summary>
    [ServiceContract(Name = "IAppStorageService", Namespace = "http://schemas.cksas.org/appstorage/")]
    internal interface IAppStorageService
    {
        /// <summary>
        /// Gets a stored object given its key in the storage.
        /// </summary>
        /// <param name="partition">The partition for which the storage item needs to be returned.</param>
        /// <param name="name">The unique name of the storage item in the storage.</param>
        /// <returns>
        /// An instance of <see cref="StorageItem"/> containing information about the storage item
        /// </returns>
        [OperationContract(Name = "GetStorageItem", Action = "http://schemas.cksas.org/appstorage/GetStorageItem")]
        StorageItem GetStorageItem(StoragePartition partition, string name);

        /// <summary>
        /// Adds the stored item to the underlying storage
        /// </summary>
        /// <param name="partition">The partition for which the storage item is indeed.</param>
        /// <param name="name">The unique name of the item in the storage.</param>
        /// <param name="item">The item information that needs to be stored.</param>
        /// <returns>
        /// An instance of <see cref="StorageItem" /> containing the newly created storage item details
        /// </returns>
        [OperationContract(Name = "AddStorageItem", Action = "http://schemas.cksas.org/appstorage/AddStorageItem")]
        StorageItem AddStorageItem(StoragePartition partition, string name, StorageItem item);

        /// <summary>
        /// Updates the stored item in the underlying storage
        /// </summary>
        /// <param name="partition">The partition for which the storage item is indeed.</param>
        /// <param name="name">The unique name of the item in the storage.</param>
        /// <param name="item">The item information that needs to be stored.</param>
        /// <returns>
        /// An instance of <see cref="StorageItem" /> containing the newly created storage item details
        /// </returns>
        [OperationContract(Name = "UpdateStorageItem", Action = "http://schemas.cksas.org/appstorage/UpdateStorageItem")]
        StorageItem UpdateStorageItem(StoragePartition partition, string name, StorageItem item);

        /// <summary>
        /// Deletes the storage item from the underlying storage
        /// </summary>
        /// <param name="partition">The partition where the storage item exists.</param>
        /// <param name="name">The name of the storage item in the storage.</param>
        [OperationContract(Name = "DeleteStorageItem", Action = "http://schemas.cksas.org/appstorage/DeleteStorageItem")]
        void DeleteStorageItem(StoragePartition partition, string name);
    }
}